# 为测试注册功能，我们需要一千个手机号和密码。请设计一个函数产生指定数量的手机号和密码，该函数返回一个手机号和密码的字典列表。
# 要求，手机号和密码都不能重复，且密码必须包含大小写与下划线，可包含数字，长度不小于8，不大于16。
# 最终输出结果可能为
# [{"phone",""13456782344", "passord": "Ss_12345678"},{"phone",""13956782354", "passord": "S7Gj45678"}]

import  random
def num_phone():
   str_start=random.choice(['13','15','16','17','18'])
   str_end=''.join(random.sample('0123456789',9))
   str_phone=str_start+str_end
   return str_phone

import random
def genarate_code():
   i=random.randint(8,16)
   lst = [chr(str1) for str1 in range(65, 91)]+[chr(str2) for str2 in range(97, 123)]+[chr(str3) for str3 in range(48, 58)]
   # print(lst)
   lst_da=[chr(str4) for str4 in range(65, 91)]
   lst_xiao=[chr(str5) for str5 in range(65, 91)]
   # lst_must=[chr(i) for i in range(65, 91)]+[chr(i) for i in range(97, 123)]
   lst.append('_')
   # lst_must.append('_')
   # str_must=''.join(lst_must)
   # print(str_must)
   list_code=[]
   list_code.append(random.choice(lst_da))
   list_code.append(random.choice(lst_xiao))
   list_code.append('_')


   for x in range(i-3):

       x=random.choice(lst)
       list_code.insert(random.randint(0,i-3),x)
   a=''.join(list_code)
   return a
def num_code(num):
   phone_pwd_list = []
   while True:
        phone = num_phone()
        password = genarate_code()
        for phone_pwd in phone_pwd_list:
            if phone == phone_pwd.get('phone') or password == phone_pwd.get('password'):
                break

        phone_pwd_list.append({'phone': phone, 'password': password})
        if len(phone_pwd_list) >= num:
                return phone_pwd_list


# print(genarate_code())
# print(num_phone())
# dic={}
# dic[num_phone()]=genarate_code()
# print(dic)
if __name__ == '__main__':
    number1=int(input("请输入需要生成的手机号和密码的数量："))
    print(num_code(number1))